package flymoke.generic.inter;

import java.util.Random;

public class FruitTest implements Generator<Fruit> {
	private Class[] fruitTest = { Apple.class, Bananla.class, Orange.class,
			Peach.class };
	private Random random = new Random(47);

	public FruitTest() {
	}

	private int size = 0;

	public FruitTest(int sz) {
		this.size = sz;
	}

	@Override
	public Fruit next() {
		
			int num = random.nextInt(fruitTest.length);
			try {
				return (Fruit) fruitTest[num]
						.newInstance();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		return null;
	}

	public static void main(String[] args) {
		FruitTest test = new FruitTest();
		for (int i = 0; i < 6; i++) {
			System.out.println(test.next());
		}
	}
}
